package com.system.login.controller;


import com.system.login.model.Comment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.mvc.support.RedirectAttributesModelMap;

import javax.servlet.http.HttpServletRequest;
import java.util.List;


@Controller
public class CommentController {

    @Autowired
    private CommentPostController commentPostController;


    @RequestMapping(value = "/comments")
    public String getComment(ModelMap modelMap, @RequestParam("name") String name, HttpServletRequest request, RedirectAttributesModelMap redirectAttributesModelMap) {


        List<Comment> comment = commentPostController.getcomments(name);


        modelMap.addAttribute("comments", comment);
       
        modelMap.addAttribute("name", name);
        redirectAttributesModelMap.addAttribute("name", name);
       

       
        return "comment";
    }


}
